package cn.edu.suda.catalina.util;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;

import java.util.Map;

/**
 * Created by gzy on 2016/6/17.
 */

public class SharedPreferencesUtil {

    public static void clearSharedPreferences(Context context) {

        SharedPreferences.Editor editor = context.getSharedPreferences("risk", Context.MODE_PRIVATE).edit();
        editor.clear().commit();
    }

    public static void editSharedPreferences(Context context, Map<String, Integer> data) {

        SharedPreferences.Editor editor = context.getSharedPreferences("risk", Context.MODE_APPEND).edit();
        for (String key : data.keySet()) {
            editor.putInt(key, data.get(key));
        }
        editor.commit();
    }

    public static int loadSharedPreferences(Context context, String key) {

        SharedPreferences sharedPreferences = context.getSharedPreferences("risk", Context.MODE_PRIVATE);
        return sharedPreferences.getInt(key, 0);
    }
}
